#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e6 + 10;

int n, m;
int fa[N], a[N];
vec G[N];
veg Q[N];
multiset < db > f[N];
ll ans[N];

void merge(multiset < db > &f, multiset < db > &g) {
	if(f.size() < g.size()) swap(f, g);
	for(auto d : g) f.insert(d);
}

void dfs(int x) {
	cerr << x << endl;
	for(auto y : G[x]) {
		cerr << x << " -> " << y << endl; dfs(y); merge(f[x], f[y]);
	}
	int cnt = 0; db lst = 0; db val = 0;
	if(a[x] >= 0) f[x].insert(-a[x]); 
	else {
		f[x].insert(-a[x]);
		/*
		if(!f[x].size()) {
			f[x].insert(-a[x]);
		}
		else
			while(f[x].size()) {
				db t = *f[x].begin(); f[x].erase(f[x].begin());
				if(val + (t - lst) * cnt + a[x] >= 0) {
					db pos = -(val + a[x]) / cnt + lst;
					while(cnt--) f[x].insert(pos);
					f[x].insert(pos); break;
				}
				val = val + (t - lst) * cnt; lst = t; cnt++;
			}
		*/
	}
	for(auto d : Q[x]) {
		int id = d.se, qt = d.fi;
		auto it = f[x].begin();
		db val = 0, lst = 0; int cnt = 0;
		while(it != f[x].end()) {
			db t = *it;
			if(t >= qt) {
				ans[id] = round(val + (qt - lst) * cnt); break;
			}
			val = val + (t - lst) * cnt; lst = t; cnt++; it++;
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	n = in, m = in; rep(i, 2, n) fa[i] = in, G[fa[i]].pb(i);
	rep(i, 1, n) a[i] = in;
	rep(i, 1, m) { int u = in, x = in; Q[u].pb({ i, x }); }
	cerr << "!" << endl;
	dfs(1); rep(i, 1, m) printf("%lld\n", ans[i]);
}
